
 <!DOCTYPE HTML>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  
    <title>CSS的position和z-index有关 | Here. There.</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=3, minimum-scale=1">
    
    <meta name="author" content="被删">
    
    <meta name="description" content="今天刚好kk妹子问我关于position的一些问题，就打算整理一下，希望用比较清晰明了的方式解释一下CSS的position是怎么个玩法。顺便也进行一下z-index相关的说明。">
    
    
    
    
    <link rel="alternate" href="/atom.xml" title="Here. There." type="application/atom+xml">
    
    
    <link rel="icon" href="/img/favicon.ico">
    
    
    <link rel="apple-touch-icon" href="/img/pacman.jpg">
    <link rel="apple-touch-icon-precomposed" href="/img/pacman.jpg">
    
    <link rel="stylesheet" href="/css/style.css">
    
<script type="text/javascript">
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "//hm.baidu.com/hm.js?3d902de4a19cf2bf179534ffd2dd7b7f";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script>

</head>

  <body>
    <header>
      <div>
		
			<div id="imglogo">
				<a href="/"><img src="/img/sun.png" alt="Here. There." title="Here. There."/></a>
			</div>
			
			<div id="textlogo">
				<h1 class="site-name"><a href="/" title="Here. There.">Here. There.</a></h1>
				<h2 class="blog-motto">Love ice cream. Love sunshine. Love life. Love the world. Love myself. Love you.</h2>
			</div>
			<div class="navbar"><a class="navbutton navmobile" href="#" title="菜单">
			</a></div>
			<nav class="animated">
				<ul>
					
						<li><a href="/">首页</a></li>
					
						<li><a href="https://github.com/godbasin/godbasin.github.io">所有文章</a></li>
					
						<li><a href="/archives">归档</a></li>
					
						<li><a href="/categories">分类</a></li>
					
						<li><a href="https://godbasin.github.io/front-end-playground">前端游乐场</a></li>
					
						<li><a href="/about">关于我</a></li>
					
				</ul>
			</nav>			
</div>

    </header>
    <div id="container">
      <div id="main" class="post" itemscope itemprop="blogPost">
	<article itemprop="articleBody"> 
		<header class="article-info clearfix">
  <h1 itemprop="name">
    
      <a href="/2016/06/25/about-position/" title="CSS的position和z-index有关" itemprop="url">CSS的position和z-index有关</a>
  </h1>
  <p class="article-author">By
    
      <a href="https://godbasin.github.io" title="被删">被删</a>
    </p>
  <p class="article-time">
    <time datetime="2016-06-25T04:03:10.000Z" itemprop="datePublished">2016-06-25</time>
    更新日期:<time datetime="2018-08-18T15:22:20.249Z" itemprop="dateModified">2018-08-18</time>
    
  </p>
</header>
	<div class="article-content">
		
		
		<div id="toc" class="toc-article">
			<strong class="toc-title">文章目录</strong>
		<ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#CSS-position属性"><span class="toc-number">1.</span> <span class="toc-text">CSS position属性</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#w3c的position"><span class="toc-number">1.1.</span> <span class="toc-text">w3c的position</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#文档流"><span class="toc-number">1.2.</span> <span class="toc-text">文档流</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#static与文档流"><span class="toc-number">1.3.</span> <span class="toc-text">static与文档流</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#relative与文档流"><span class="toc-number">1.4.</span> <span class="toc-text">relative与文档流</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#absolute与文档流"><span class="toc-number">1.5.</span> <span class="toc-text">absolute与文档流</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#无定位的absolute"><span class="toc-number">1.6.</span> <span class="toc-text">无定位的absolute</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#fixed与文档流"><span class="toc-number">1.7.</span> <span class="toc-text">fixed与文档流</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#z-index"><span class="toc-number">2.</span> <span class="toc-text">z-index</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#z-index简述"><span class="toc-number">2.1.</span> <span class="toc-text">z-index简述</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#z-index在同级元素下的效果"><span class="toc-number">2.2.</span> <span class="toc-text">z-index在同级元素下的效果</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#z-index在不同级元素下的效果"><span class="toc-number">2.3.</span> <span class="toc-text">z-index在不同级元素下的效果</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#z-index与position-fixed"><span class="toc-number">2.4.</span> <span class="toc-text">z-index与position: fixed</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#z-index总结"><span class="toc-number">2.5.</span> <span class="toc-text">z-index总结</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#结束语"><span class="toc-number">3.</span> <span class="toc-text">结束语</span></a></li></ol>
		</div>
		
		<p>今天刚好kk妹子问我关于position的一些问题，就打算整理一下，希望用比较清晰明了的方式解释一下CSS的position是怎么个玩法。<br>顺便也进行一下z-index相关的说明。<br><a id="more"></a></p>
<h2 id="CSS-position属性"><a href="#CSS-position属性" class="headerlink" title="CSS position属性"></a>CSS position属性</h2><hr>
<h3 id="w3c的position"><a href="#w3c的position" class="headerlink" title="w3c的position"></a>w3c的position</h3><p>这里借用<a href="http://www.w3school.com.cn/cssref/pr_class_position.asp" target="_blank" rel="external">w3c</a>上的说明</p>
<ul>
<li>absolute    <ul>
<li>生成绝对定位的元素，相对于static定位以外的第一个父元素进行定位。</li>
<li>元素的位置通过”left”, “top”, “right”以及”bottom”属性进行规定。</li>
</ul>
</li>
<li>fixed    <ul>
<li>生成绝对定位的元素，相对于浏览器窗口进行定位。</li>
<li>元素的位置通过”left”, “top”, “right”以及”bottom”属性进行规定。</li>
</ul>
</li>
<li>relative    <ul>
<li>生成相对定位的元素，相对于其正常位置进行定位。</li>
<li>因此，”left:20”会向元素的 LEFT位置添加 20像素。</li>
</ul>
</li>
<li>static    <ul>
<li>默认值。没有定位，元素出现在正常的流中（忽略top, bottom, left, right或者z-index声明）。</li>
</ul>
</li>
<li>inherit    <ul>
<li>规定应该从父元素继承position属性的值。</li>
</ul>
</li>
</ul>
<h3 id="文档流"><a href="#文档流" class="headerlink" title="文档流"></a>文档流</h3><ul>
<li>什么是文档流<br>相信大家刚开始接触position属性的时候，都会被“文档流”、“流”这样的概念给吓坏了。</li>
<li>正常的文档流也叫普通流，在HTML里面的写法就是从上到下，从左到右的排版布局</li>
</ul>
<h3 id="static与文档流"><a href="#static与文档流" class="headerlink" title="static与文档流"></a>static与文档流</h3><p>如图，<a href="https://about-position-1255459943.file.myqcloud.com/position-static.html" target="_blank" rel="external">查看页面效果</a><br><figure class="highlight css"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line"><span class="selector-tag">a</span>, <span class="selector-tag">p</span>, <span class="selector-tag">div</span> &#123; <span class="attribute">border</span>: solid <span class="number">1px</span> red; &#125;</div><div class="line"><span class="selector-class">.static</span> &#123; <span class="attribute">position</span>: static; <span class="attribute">left</span>: <span class="number">100px</span>; <span class="attribute">top</span>: <span class="number">100px</span>; &#125;</div></pre></td></tr></table></figure></p>
<p><img src="https://github-imglib-1255459943.cos.ap-chengdu.myqcloud.com/53ETM3GNX7ZV65W%5DW~%28%7BZK3.png" alt="image"><br>可见，此时添加定位（left: 100px; top: 100px;）是无效的</p>
<h3 id="relative与文档流"><a href="#relative与文档流" class="headerlink" title="relative与文档流"></a>relative与文档流</h3><p>relative保持原有文档流，但相对本身的原始位置发生位移，且占空间<br>如图，<a href="https://about-position-1255459943.file.myqcloud.com/position-relative.html" target="_blank" rel="external">查看页面效果</a><br><figure class="highlight css"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line"><span class="selector-tag">a</span>, <span class="selector-tag">p</span>, <span class="selector-tag">div</span> &#123; <span class="attribute">border</span>: solid <span class="number">1px</span> red; &#125;</div><div class="line"><span class="selector-class">.relative</span> &#123; <span class="attribute">position</span>: relative; <span class="attribute">left</span>: <span class="number">100px</span>; <span class="attribute">top</span>: <span class="number">100px</span>; &#125;</div></pre></td></tr></table></figure></p>
<p><img src="https://github-imglib-1255459943.cos.ap-chengdu.myqcloud.com/PN1G~%5DQFF@E7AVRQJ9Z8%28JH.png" alt="image"><br>可见：</p>
<ul>
<li>relative元素也遵循从上到下，从左到右的排版布局</li>
<li>relative相对于其正常位置进行定位，在这里设置了relative的元素相对其原本位置（position=static）进行位移</li>
<li>relative元素占有原本位置，因此下一个元素会排到该元素后方</li>
<li>relative元素占位不会随着定位的改变而改变。也就是说relative在文档流中占有的位置与其原本位置（position=static）相同<br>这里有个需要注意的地方： 虽然relative元素占位与static相同，但会溢出父元素，撑开整个页面（document）。<br>如图，<a href="https://about-position-1255459943.file.myqcloud.com/position-relative-occupation.html" target="_blank" rel="external">查看页面效果</a><br><img src="https://github-imglib-1255459943.cos.ap-chengdu.myqcloud.com/LHRK4@9K$YE1%25KMB%29G9%60~%7B8.png" alt="image"><br>可以relative元素撑开父元素看到页面底部有滚动条。<br>此时给父元素设置overflow: hidden;则可以隐藏溢出部分，如图<br><img src="https://github-imglib-1255459943.cos.ap-chengdu.myqcloud.com/KGE~71FX8H7DW6VNYC1T00M.png" alt="image"></li>
</ul>
<h3 id="absolute与文档流"><a href="#absolute与文档流" class="headerlink" title="absolute与文档流"></a>absolute与文档流</h3><p>absolute脱离文档流，相对于其包含块来定位，且不占位<br>如图<br><figure class="highlight css"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line"><span class="selector-class">.parent</span>&#123; <span class="attribute">border</span>: solid <span class="number">1px</span> blue; <span class="attribute">width</span>: <span class="number">300px</span>; &#125; </div><div class="line"><span class="selector-class">.parent</span> &gt; <span class="selector-tag">div</span>&#123; <span class="attribute">border</span>: solid <span class="number">1px</span> red; <span class="attribute">height</span>: <span class="number">100px</span>; <span class="attribute">width</span>: <span class="number">300px</span>; &#125; </div><div class="line"><span class="selector-class">.absolute</span>&#123; <span class="attribute">position</span>: absolute; <span class="attribute">left</span>: <span class="number">100px</span>; <span class="attribute">height</span>: <span class="number">100px</span>; &#125;</div></pre></td></tr></table></figure></p>
<p><img src="https://github-imglib-1255459943.cos.ap-chengdu.myqcloud.com/75%5D1@NRTQ8$U9KTQ66SPL2A.png" alt="image"><br>可见：</p>
<ul>
<li>absolute元素脱离文档流</li>
<li>absolute元素不占位，因此下一个符合普通流的元素会略过absolute元素排到其上一个元素的后方</li>
</ul>
<p>此时对于absolute元素的占位依然不大清晰，接下来我们给父元素添加margin-left: 200px的样式，如图<br><img src="https://github-imglib-1255459943.cos.ap-chengdu.myqcloud.com/07J25Y0F~@O%5D@ZAGZ~%25%60%28%29Y.png" alt="image"><br>很明显，absolute元素位置没有发生改变，这是因为该元素相对于document进行定位。</p>
<ul>
<li>absolute元素的定位是相对于static定位以外的第一个父元素进行定位</li>
<li>当absolute的父元素position为static，则会继续往上查找，直到找到一个为relative/absolute/fixed的父元素作为定位参照物</li>
<li>当absolute没有position为非static的父元素时，则会进行全局定位，即相对于文档document进行定位</li>
</ul>
<p>所以我们可以给父元素加上position=relative的样式，如图<br><img src="https://github-imglib-1255459943.cos.ap-chengdu.myqcloud.com/~NPVE%7D%7DZFR3$PH%609%5DFJQF2Y.png" alt="image"><br>此时absolute元素则相对于父元素进行定位，<a href="https://about-position-1255459943.file.myqcloud.com/position-absolute.html" target="_blank" rel="external">查看页面效果</a>。</p>
<h3 id="无定位的absolute"><a href="#无定位的absolute" class="headerlink" title="无定位的absolute"></a>无定位的absolute</h3><p>在使用absolute进行定位时，若我们只是将元素设置为position: absolute，而不对其进行定位（top, bottom, left, right），会是怎样的情况呢？<br>如图，<a href="https://about-position-1255459943.file.myqcloud.com/position-absolute-without-position.html" target="_blank" rel="external">查看页面效果</a><br><img src="https://github-imglib-1255459943.cos.ap-chengdu.myqcloud.com/CG_14%7DVI%28TDCYFK%7BE$8SC%287.png" alt="image"><br>可见：</p>
<ul>
<li>未设置定位的absolute元素，其定位与其原本位置（position=static）相同</li>
<li>此时absolute元素依然不占位，因此下一个符合普通流的元素会略过absolute元素排到其上一个元素的后方</li>
</ul>
<h3 id="fixed与文档流"><a href="#fixed与文档流" class="headerlink" title="fixed与文档流"></a>fixed与文档流</h3><p>fixed脱离文档流，相对于浏览器窗口来定位，且不占位<br>如图<br><figure class="highlight css"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line"><span class="selector-class">.parent</span> &#123; <span class="attribute">border</span>: solid <span class="number">1px</span> blue; <span class="attribute">width</span>: <span class="number">300px</span>; &#125; </div><div class="line"><span class="selector-class">.parent</span> &gt; <span class="selector-tag">div</span> &#123; <span class="attribute">border</span>: solid <span class="number">1px</span> red; <span class="attribute">height</span>: <span class="number">100px</span>; <span class="attribute">width</span>: <span class="number">300px</span>; &#125; </div><div class="line"><span class="selector-class">.fixed</span> &#123; <span class="attribute">position</span>: fixed; <span class="attribute">left</span>: <span class="number">100px</span>; <span class="attribute">top</span>: <span class="number">100px</span>; <span class="attribute">background</span>: yellow; &#125;</div></pre></td></tr></table></figure></p>
<p><img src="https://github-imglib-1255459943.cos.ap-chengdu.myqcloud.com/%28FNOAFPIA%5B80%25F%7D6%5B0CQ2%7DE.png" alt="image"><br>似乎跟相对于文档定位时的absolute元素没什么两样，即</p>
<ul>
<li>fixed元素脱离文档流</li>
<li>fixed元素不占位</li>
</ul>
<p>接来下我们将页面填充满，如图，<a href="https://about-position-1255459943.file.myqcloud.com/position-fixed-absolute.html" target="_blank" rel="external">查看页面效果</a><br><img src="https://github-imglib-1255459943.cos.ap-chengdu.myqcloud.com/K4OGL%5BF5~XP9NLRW%254X%7B55X.png" alt="image"><br>当我们进行页面滚动的时候，fixed元素位置没有发生变化，可见：</p>
<ul>
<li>fixed相对于浏览器窗口来定位，不管是否有static定位以外的父元素</li>
<li>absolute元素会随着页面的滚动而滚动，而fixed不会</li>
</ul>
<p>也就是说，fixed元素相对于浏览器窗口进行定位，而无有static定位以外的父元素的absolute，则相对于document进行定位</p>
<h2 id="z-index"><a href="#z-index" class="headerlink" title="z-index"></a>z-index</h2><hr>
<h3 id="z-index简述"><a href="#z-index简述" class="headerlink" title="z-index简述"></a>z-index简述</h3><ul>
<li>z-index属性定义了第三维度，默认为0</li>
<li>z-index属性设置元素的堆叠顺序，拥有更高堆叠顺序的元素总是会处于堆叠顺序较低的元素的前面</li>
<li>z-index只能在position属性值为relative或absolute或fixed的元素上有效<br>-</li>
</ul>
<h3 id="z-index在同级元素下的效果"><a href="#z-index在同级元素下的效果" class="headerlink" title="z-index在同级元素下的效果"></a>z-index在同级元素下的效果</h3><p>如图，<a href="https://about-position-1255459943.file.myqcloud.com/position-z-index-same-level.html" target="_blank" rel="external">查看页面效果</a><br><img src="https://github-imglib-1255459943.cos.ap-chengdu.myqcloud.com/%60X74TE9%7D%28OFY%7BUK$MAW%5B%7B5O.png" alt="image"><br>可见：</p>
<ul>
<li>当同级元素不设置z-index或者z-index相等时，后面的元素会叠在前面的元素上方</li>
<li>当同级元素z-index不同时，z-index大的元素会叠在z-index小的元素上方</li>
</ul>
<h3 id="z-index在不同级元素下的效果"><a href="#z-index在不同级元素下的效果" class="headerlink" title="z-index在不同级元素下的效果"></a>z-index在不同级元素下的效果</h3><p>如图，<a href="https://about-position-1255459943.file.myqcloud.com/position-z-index-diff-level-1.html" target="_blank" rel="external">查看页面效果</a><br><img src="https://github-imglib-1255459943.cos.ap-chengdu.myqcloud.com/Q%7BFVVGE6NSP8WB~_3P7SZ$G.png" alt="image"><br>仔细看会发现个很有意思的现象，parent1和parent2为同级元素，parent2叠在parent1上方，但是parent2子元素却位于parent1子元素的下方。<br>parent1和parent2的position均为relative，是不是有些难以理解？这是因为：</p>
<ul>
<li>当向上追溯找不到含有z-index值的父元素的情况下，则可以视为自由的z-index元素</li>
<li>自由的z-index元素可以与其他自由的定位元素来比较z-index的值，决定其堆叠顺序</li>
</ul>
<p>在这里，parent1和parent2均无设置z-index值，故在这里子元素的堆叠顺序是由自己的z-index值决定的。<br>接下来我们为两个parent均加上z-index，如图，<a href="https://about-position-1255459943.file.myqcloud.com/position-z-index-diff-level-2.html" target="_blank" rel="external">查看页面效果</a><br><img src="https://github-imglib-1255459943.cos.ap-chengdu.myqcloud.com/PMVG4833%60U%29JC9%5BWK5W%601NC.png" alt="image"></p>
<p>经测试，在parent2的z-index大于或者等于parent1的z-index的时候，parent2以及它的子元素均位于parent1以及其子元素的上方。<br>而当我们设置parent2的z-index小于parent1的z-index的时候，如图<br><img src="https://github-imglib-1255459943.cos.ap-chengdu.myqcloud.com/@22C%5D%5D9~A7%28%29%5B%60LZLD@%29%7BRF.png" alt="image"><br>此时parent2以及它的子元素均位于parent1以及其子元素的下方。<br>可见：</p>
<ul>
<li>z-index值只决定同一父元素中的同级子元素的堆叠顺序</li>
<li>父元素的z-index值为子元素定义了堆叠顺序，即子元素依赖于父元素z-index值来获得页面中的堆叠顺序</li>
</ul>
<p>现在我们将parent2的z-index值取消，留下parent1的z-index值为2。<br>如图，<a href="https://about-position-1255459943.file.myqcloud.com/position-z-index-diff-level-3.html" target="_blank" rel="external">查看页面效果</a><br><img src="https://github-imglib-1255459943.cos.ap-chengdu.myqcloud.com/G%5D6CTV7PXO%28UD7B%5B%7B%60%28U693.png" alt="image"><br>可见：</p>
<ul>
<li>自由的z-index元素可以与父元素的同级兄弟定位元素来比较z-index的值，决定其堆叠顺序</li>
</ul>
<h3 id="z-index与position-fixed"><a href="#z-index与position-fixed" class="headerlink" title="z-index与position: fixed"></a>z-index与position: fixed</h3><p>当初一直认为fixed的元素有种优先级特别高的感觉，但在z-index比较上却有了新发现，如图<br><img src="https://github-imglib-1255459943.cos.ap-chengdu.myqcloud.com/IN7X7L4FJ%5DYT%7DZPG~8_I%60@R.png" alt="image"><br>经测试，在不设置z-index值或者z-index值相等时，fixed元素和absolute元素堆叠顺序均由元素在文档中的先后位置决定，后出现的会在上面。<br>接下来我们给这几个子元素加上z-index值，如图<br><img src="https://github-imglib-1255459943.cos.ap-chengdu.myqcloud.com/FMC%60R%25%25LLKVM9OQ1~5~%29GQ3.png" alt="image"><br>这时候我们会有种想法，会不会fixed元素和absolute元素的堆叠规则一样呢？<br>现在我们将fixed元素移到parent元素外面，且parent元素z-index值依然为空，如图，<a href="https://about-position-1255459943.file.myqcloud.com/position-z-index-fixed.html" target="_blank" rel="external">查看页面效果</a><br><img src="https://github-imglib-1255459943.cos.ap-chengdu.myqcloud.com/A%284RG%7BTP~2$%29%29ZE5Y2HW%7BOD.png" alt="image"><br>可见：</p>
<ul>
<li>尽管fixed定位方式与absolute不一致，它们的堆叠规则是一致的</li>
</ul>
<h3 id="z-index总结"><a href="#z-index总结" class="headerlink" title="z-index总结"></a>z-index总结</h3><ul>
<li>无z-index或者z-index值相等时，堆叠顺序均由元素在文档中的先后位置决定，后出现的会在上面</li>
<li>当向上追溯找不到含有z-index值的父元素的情况下，则可以视为自由的z-index元素</li>
<li>自由的z-index元素可以与其他自由的定位元素或者父元素的同级兄弟定位元素来比较z-index的值，决定其堆叠顺序</li>
<li>z-index值只决定同一父元素中的同级子元素的堆叠顺序</li>
<li><p>父元素的z-index值为子元素定义了堆叠顺序，即子元素依赖于父元素z-index值来获得页面中的堆叠顺序</p>
</li>
<li><p>参考<br><a href="http://www.cnblogs.com/mind/archive/2012/04/01/2198995.html" target="_blank" rel="external">浅析CSS——元素重叠及position定位的z-index顺序</a></p>
</li>
<li><p>相关代码保存在<a href="https://github.com/godbasin/godbasin.github.io/tree/blog-codes/about-position" target="_blank" rel="external">about-position</a></p>
</li>
</ul>
<h2 id="结束语"><a href="#结束语" class="headerlink" title="结束语"></a>结束语</h2><p>不得不说，写这篇文章的过程自己对position和z-index相关的原理和规则也熟悉了很多，总结也是一种学习的方式呢。</p>
  
		
		<p style="margin-top:50px;">
			查看Github有更多内容噢：<a href="https://github.com/godbasin">https://github.com/godbasin</a>
			<br>
			更欢迎来<a href="https://godbasin.github.io/front-end-playground">被删的前端游乐场</a>边撸猫边学前端噢
		</p>
	</div>
	<img src="https://github-imglib-1255459943.cos.ap-chengdu.myqcloud.com/2code2.jpg" width="200" height="200" style="display:block;margin: 0 auto;" />
	<p style="text-align: center;margin-top: 10px;margin-bottom: 20px;">码生艰难，写文不易，给我家猪囤点猫粮了喵~</p>
	<div class="author-right">
  		<p>作者：被删</p>
  		<p>出处：<a href="https://godbasin.github.io">https://godbasin.github.io</a></p>
  		<p>本文版权归作者所有，欢迎转载，但未经作者同意必须保留此段声明，且在文章页面明显位置给出原文连接，否则保留追究法律责任的权利。</p>
	</div>
		<footer class="article-footer clearfix">

  <div class="article-tags">
  
  <span></span> <a href="/tags/分享/">分享</a>
  </div>


<div class="article-categories">
  <span></span>
  <a class="article-category-link" href="/categories/CSS炒饭/">CSS炒饭</a>
</div>



<div class="article-share" id="share">

  
<!-- JiaThis Button BEGIN -->
<div class="jiathis_style_24x24">
	<a class="jiathis_button_qzone"></a>
	<a class="jiathis_button_tsina"></a>
	<a class="jiathis_button_tqq"></a>
	<a class="jiathis_button_weixin"></a>
	<a class="jiathis_button_renren"></a>
	<a href="http://www.jiathis.com/share?uid=2134021" class="jiathis jiathis_txt jtico jtico_jiathis" target="_blank"></a>
</div>
<script type="text/javascript">
var jiathis_config = {data_track_clickback:'true'};
</script>
<script type="text/javascript" src="http://v3.jiathis.com/code_mini/jia.js?uid=2134021" charset="utf-8"></script>
<!-- JiaThis Button END -->   


</div>
</footer>   	       
	</article>
	
<nav class="article-nav clearfix">
 
 <div class="prev" >
 <a href="/2016/06/26/about-display/" title="CSS的display有关">
  <strong>PREVIOUS:</strong><br/>
  <span>
  CSS的display有关</span>
</a>
</div>


<div class="next">
<a href="/2016/06/24/front-end-getting-started/"  title="我的前端入门之路">
 <strong>NEXT:</strong><br/> 
 <span>我的前端入门之路
</span>
</a>
</div>

</nav>

	<!-- 如果不是首页且没使用 `comments: false` 关闭评论，则尝试加载评论 -->

    <!-- 配置中启用多说时，导入相应代码 -->
    


</div>  
      <div class="openaside"><a class="navbutton" href="#" title="显示侧边栏"></a></div>

  <div id="toc" class="toc-aside">
  <strong class="toc-title">文章目录</strong>
  <ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#CSS-position属性"><span class="toc-number">1.</span> <span class="toc-text">CSS position属性</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#w3c的position"><span class="toc-number">1.1.</span> <span class="toc-text">w3c的position</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#文档流"><span class="toc-number">1.2.</span> <span class="toc-text">文档流</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#static与文档流"><span class="toc-number">1.3.</span> <span class="toc-text">static与文档流</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#relative与文档流"><span class="toc-number">1.4.</span> <span class="toc-text">relative与文档流</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#absolute与文档流"><span class="toc-number">1.5.</span> <span class="toc-text">absolute与文档流</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#无定位的absolute"><span class="toc-number">1.6.</span> <span class="toc-text">无定位的absolute</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#fixed与文档流"><span class="toc-number">1.7.</span> <span class="toc-text">fixed与文档流</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#z-index"><span class="toc-number">2.</span> <span class="toc-text">z-index</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#z-index简述"><span class="toc-number">2.1.</span> <span class="toc-text">z-index简述</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#z-index在同级元素下的效果"><span class="toc-number">2.2.</span> <span class="toc-text">z-index在同级元素下的效果</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#z-index在不同级元素下的效果"><span class="toc-number">2.3.</span> <span class="toc-text">z-index在不同级元素下的效果</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#z-index与position-fixed"><span class="toc-number">2.4.</span> <span class="toc-text">z-index与position: fixed</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#z-index总结"><span class="toc-number">2.5.</span> <span class="toc-text">z-index总结</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#结束语"><span class="toc-number">3.</span> <span class="toc-text">结束语</span></a></li></ol>
  </div>

<div id="asidepart">
<div class="closeaside"><a class="closebutton" href="#" title="隐藏侧边栏"></a></div>
<aside class="clearfix">

  	
	<div class="archiveslist">
		<p class="asidetitle">最近文章</p>
			<ul class="archive-list">
			
					
				<li class="archive-list-item">
					<a class="archive-list-link" href="/2019/11/15/wxapp-latest-20191115/" title="小程序开发月刊第11期（20191115）">小程序开发月刊第11期（201911...</a>
				</li>
				
			
					
				<li class="archive-list-item">
					<a class="archive-list-link" href="/2019/11/10/change-log/" title="前端 CHANGELOG 生成指南">前端 CHANGELOG 生成指南...</a>
				</li>
				
			
					
				<li class="archive-list-item">
					<a class="archive-list-link" href="/2019/11/09/wxapp-global-data-behavior/" title="小程序的奇技淫巧 -- globalDataBehavior管理全局状态">小程序的奇技淫巧 -- global...</a>
				</li>
				
			
					
				<li class="archive-list-item">
					<a class="archive-list-link" href="/2019/10/15/wxapp-latest-20191015/" title="小程序开发月刊第十期（20191015）">小程序开发月刊第十期（2019101...</a>
				</li>
				
			
					
				<li class="archive-list-item">
					<a class="archive-list-link" href="/2019/10/13/about-front-end-3-growth/" title="前端这几年--3.关于成长和焦虑">前端这几年--3.关于成长和焦虑...</a>
				</li>
				
			
					
				<li class="archive-list-item">
					<a class="archive-list-link" href="/2019/09/16/wxapp-latest-20190916/" title="小程序开发月刊第九期（20190916）">小程序开发月刊第九期（2019091...</a>
				</li>
				
			
					
				<li class="archive-list-item">
					<a class="archive-list-link" href="/2019/08/15/wxapp-latest-20190815/" title="小程序开发月刊第八期（20190815）">小程序开发月刊第八期（2019081...</a>
				</li>
				
			
					
				<li class="archive-list-item">
					<a class="archive-list-link" href="/2019/07/27/front-end-playground/" title="被删的前端游乐场建成！">被删的前端游乐场建成！</a>
				</li>
				
			
					
				<li class="archive-list-item">
					<a class="archive-list-link" href="/2019/07/21/vue-for-everyone-3/" title="9102全员学Vue--3.把页面拼成个Web应用">9102全员学Vue--3.把页面拼...</a>
				</li>
				
			
					
				<li class="archive-list-item">
					<a class="archive-list-link" href="/2019/07/15/wxapp-latest-20190715/" title="小程序开发月刊第七期（20190715）">小程序开发月刊第七期（2019071...</a>
				</li>
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
				
			
			</ul>
	</div>


  
  <div class="archiveslist">
    <p class="asidetitle"><a href="/archives">归档</a></p>
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/11/">十一月 2019</a><span class="archive-list-count">3</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/10/">十月 2019</a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/09/">九月 2019</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/08/">八月 2019</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/07/">七月 2019</a><span class="archive-list-count">4</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/06/">六月 2019</a><span class="archive-list-count">4</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/05/">五月 2019</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/04/">四月 2019</a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/03/">三月 2019</a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/02/">二月 2019</a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/01/">一月 2019</a><span class="archive-list-count">3</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/12/">十二月 2018</a><span class="archive-list-count">4</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/11/">十一月 2018</a><span class="archive-list-count">4</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/10/">十月 2018</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/09/">九月 2018</a><span class="archive-list-count">3</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/08/">八月 2018</a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/07/">七月 2018</a><span class="archive-list-count">3</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/06/">六月 2018</a><span class="archive-list-count">3</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/05/">五月 2018</a><span class="archive-list-count">5</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/04/">四月 2018</a><span class="archive-list-count">4</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/03/">三月 2018</a><span class="archive-list-count">7</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/02/">二月 2018</a><span class="archive-list-count">4</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/01/">一月 2018</a><span class="archive-list-count">9</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/12/">十二月 2017</a><span class="archive-list-count">5</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/11/">十一月 2017</a><span class="archive-list-count">3</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/10/">十月 2017</a><span class="archive-list-count">5</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/09/">九月 2017</a><span class="archive-list-count">6</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/08/">八月 2017</a><span class="archive-list-count">11</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/07/">七月 2017</a><span class="archive-list-count">9</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/06/">六月 2017</a><span class="archive-list-count">10</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/05/">五月 2017</a><span class="archive-list-count">15</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/04/">四月 2017</a><span class="archive-list-count">7</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/03/">三月 2017</a><span class="archive-list-count">10</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/02/">二月 2017</a><span class="archive-list-count">41</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/01/">一月 2017</a><span class="archive-list-count">6</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/12/">十二月 2016</a><span class="archive-list-count">7</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/11/">十一月 2016</a><span class="archive-list-count">9</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/10/">十月 2016</a><span class="archive-list-count">5</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/09/">九月 2016</a><span class="archive-list-count">7</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/08/">八月 2016</a><span class="archive-list-count">9</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/07/">七月 2016</a><span class="archive-list-count">14</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/06/">六月 2016</a><span class="archive-list-count">9</span></li></ul>
  </div>


  
<div class="archiveslist">
	<p class="asidetitle"><a href="/categories">分类</a></p>
		<ul class="archive-list">
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/CSS炒饭/" title="CSS炒饭">CSS炒饭<sup>3</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/D3小馒头/" title="D3小馒头">D3小馒头<sup>8</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/angular2火锅/" title="angular2火锅">angular2火锅<sup>25</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/angular混搭/" title="angular混搭">angular混搭<sup>33</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/box2djs方糖/" title="box2djs方糖">box2djs方糖<sup>34</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/cyclejs哈根达斯/" title="cyclejs哈根达斯">cyclejs哈根达斯<sup>8</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/jQuery杂烩/" title="jQuery杂烩">jQuery杂烩<sup>3</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/js什锦/" title="js什锦">js什锦<sup>26</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/react沙拉/" title="react沙拉">react沙拉<sup>16</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/three-js奶茶/" title="three.js奶茶">three.js奶茶<sup>5</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/vue八宝粥/" title="vue八宝粥">vue八宝粥<sup>29</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/webpack宾治/" title="webpack宾治">webpack宾治<sup>9</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/web乱炖/" title="web乱炖">web乱炖<sup>2</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/前端满汉全席/" title="前端满汉全席">前端满汉全席<sup>8</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/喵/" title="喵">喵<sup>2</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/小程序双皮奶/" title="小程序双皮奶">小程序双皮奶<sup>27</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/工作这杯茶/" title="工作这杯茶">工作这杯茶<sup>5</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/应用巧克力盒/" title="应用巧克力盒">应用巧克力盒<sup>2</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/思想棉花糖/" title="思想棉花糖">思想棉花糖<sup>8</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/柴米油盐工具集/" title="柴米油盐工具集">柴米油盐工具集<sup>1</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/自动化甜筒/" title="自动化甜筒">自动化甜筒<sup>1</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/categories/非前端钙片/" title="非前端钙片">非前端钙片<sup>7</sup></a>
			</li>
		
		</ul>
</div>


  
<div class="archiveslist">
	<p class="asidetitle">标签</p>
		<ul class="archive-list">
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/tags/分享/" title="分享">分享<sup>44</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/tags/原创部件/" title="原创部件">原创部件<sup>1</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/tags/心态/" title="心态">心态<sup>5</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/tags/教程/" title="教程">教程<sup>73</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/tags/晒猫/" title="晒猫">晒猫<sup>2</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/tags/笔记/" title="笔记">笔记<sup>121</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/tags/算法/" title="算法">算法<sup>9</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/tags/自制插件/" title="自制插件">自制插件<sup>2</sup></a>
			</li>
		
			<li class="archive-list-item">
				<a class="archive-list-link" href="/tags/逻辑实现/" title="逻辑实现">逻辑实现<sup>5</sup></a>
			</li>
		
		</ul>
</div>


    <div class="archiveslist">
    <p class="asidetitle"><a href="/archives">about</a></p>
      <ul class="archive-list">
      	<li class="archive-list-item">
      		<a>wangbeishan@163.com</a>
      		<a href="https://github.com/godbasin">github.com/godbasin</a>
      	</li>
      </ul>
  </div>

  <div class="rsspart">
	<a href="/atom.xml" target="_blank" title="rss">RSS 订阅</a>
</div>

</aside>
</div>
    </div>
    <footer><div id="footer" >
	
	<section class="info">
		<p> 即使梦想再小，却很伟大 ^_^ </p>
	</section>
	 
		<p class="copyright">Powered by <a href="http://hexo.io" target="_blank" title="hexo">hexo</a> and Theme by <a href="https://github.com/A-limon/pacman" target="_blank" title="Pacman">Pacman</a> © 2019 
		
		<a href="https://godbasin.github.io" target="_blank" title="被删">被删</a>
		
		</p>
</div>
</footer>
    <script src="/js/jquery-2.1.0.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){ 
  $('.navbar').click(function(){
    $('header nav').toggleClass('shownav');
  });
  var myWidth = 0;
  function getSize(){
    if( typeof( window.innerWidth ) == 'number' ) {
      myWidth = window.innerWidth;
    } else if( document.documentElement && document.documentElement.clientWidth) {
      myWidth = document.documentElement.clientWidth;
    };
  };
  var m = $('#main'),
      a = $('#asidepart'),
      c = $('.closeaside'),
      o = $('.openaside');
  $(window).resize(function(){
    getSize(); 
    if (myWidth >= 1024) {
      $('header nav').removeClass('shownav');
    }else
    {
      m.removeClass('moveMain');
      a.css('display', 'block').removeClass('fadeOut');
      o.css('display', 'none');
      
      $('#toc.toc-aside').css('display', 'none');
        
    }
  });
  c.click(function(){
    a.addClass('fadeOut').css('display', 'none');
    o.css('display', 'block').addClass('fadeIn');
    m.addClass('moveMain');
  });
  o.click(function(){
    o.css('display', 'none').removeClass('beforeFadeIn');
    a.css('display', 'block').removeClass('fadeOut').addClass('fadeIn');      
    m.removeClass('moveMain');
  });
  $(window).scroll(function(){
    o.css("top",Math.max(80,260-$(this).scrollTop()));
  });
});
</script>

<script type="text/javascript">
$(document).ready(function(){ 
  var ai = $('.article-content>iframe'),
      ae = $('.article-content>embed'),
      t  = $('#toc'),
      h  = $('article h2')
      ah = $('article h2'),
      ta = $('#toc.toc-aside'),
      o  = $('.openaside'),
      c  = $('.closeaside');
  if(ai.length>0){
    ai.wrap('<div class="video-container" />');
  };
  if(ae.length>0){
   ae.wrap('<div class="video-container" />');
  };
  if(ah.length==0){
    t.css('display','none');
  }else{
    c.click(function(){
      ta.css('display', 'block').addClass('fadeIn');
    });
    o.click(function(){
      ta.css('display', 'none');
    });
    $(window).scroll(function(){
      ta.css("top",Math.max(140,320-$(this).scrollTop()));
    });
  };
});
</script>







  </body>
</html>
